const tools = require("./tools");

const create = function( obj , o ){
    let nobj = new Proxy(
        obj , 
        {
            get(target, key, receiver) {
                let re = null;
                let data = target._data || target._d;
                if( data && !tools.isType( data[key] , "Undefined") ){
                    re= Reflect.get(data, key, receiver);
                }else if( !tools.isType( target[key] , "Undefined") ){
                    re= Reflect.get(target, key, receiver);
                }else {
                    re= null;
                }

                if( o && tools.isType( o.get , "Function") ){
                    re = o.get( re );
                }
                return re;
            }
    })

    return nobj;
}

module.exports = create; 